<?php
if (isloggedin()) {
    $selectedVersion = 0;
    if (isset($_SESSION['CV'])) {
        $selectedVersion = $_SESSION['CV']->id;
    }

    $versions = get_user_versions();
    echo '<div id="cv-list">Versions:<ul>';
    foreach ($versions as $version) {
        $selected = "";
        if ($version->id == $selectedVersion) {
            $selected = "class='selected'";
        }
        echo "<li $selected vid='{$version->id}'>{$version->name}</li>";
    }
    echo '</ul></div>';
}